package com.sgb.kjwl.view.ui.adapter.shopping;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ImageSpan;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemMachineListBinding;
import com.sgb.kjwl.databinding.ItemShopLeaseDeviceBinding;
import com.sgb.kjwl.model.entity.ShopLeaseEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.DateUtils;

import java.util.List;

public class ShopMachineAdapter extends BaseRecycleAdapter<ShopLeaseEntity> {

    public ShopMachineAdapter(Context context, List<ShopLeaseEntity> datas) {
        super(context, R.layout.item_shop_lease_device, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final ShopLeaseEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        ItemShopLeaseDeviceBinding binding = (ItemShopLeaseDeviceBinding) holder.getmBinding();
        binding.titleView.setText(entity.getTitle());
        binding.tvArea.setText(entity.getCityName() + " " + entity.getAreaName());
        if (!TextUtils.isEmpty(entity.getPrice()) && Double.parseDouble(entity.getPrice()) > 0) {
            binding.priceView.setText(entity.getPrice() + entity.getPriceUnitName());
        } else {
            binding.priceView.setText("面议");
        }

//        try {
//            binding.tvTime.setText(DateUtils.stampToDay(entity.getUpdateTime()));
//        } catch (Exception e) {
//
//        }
    }
}
